Reactive functions are something between variables (cold/static) and a function (hot/dynamic) => a function with memory.
First time called: run like a function Second time called: read from cache (if nothing changed)
Reactives re-execute automatically, when dependencies change input –> output.
Example syntax:
library(shiny)
server <- function(input, output, session) {
dataset <- reactive({ data(mtcars) })
print(dataset)
}
server()
## reactive({
## data(mtcars)
## })
dataset() # notice, that dataset is now a function
Reactives deal with the communication between the UI and the Server. Web developers call this concept “callback”. Usually a tedious experience, but shiny manages this almost automatically for you. This is the major USP of shiny (taking care of the dependencies).